/*
 * stimer.h
 *
 *  Created on: 2021121
 *      Author: hello
 */

#ifndef STIMER_H_
#define STIMER_H_

#include <stdint.h>

typedef enum
{
	STIMER_MODE_SINGLE = 1,
	STIMER_MODE_REPEAT = 2,
}stimet_mode_t;

typedef struct _stimer
{
	const char* name;
	uint32_t timeout_ticks;
	uint32_t startup_ticks;
	void (*callback)(void* arg);
	stimet_mode_t mode;
	void* arg;
	struct _stimer* next;
}stimer_t;

void stimer_init(stimer_t* timer, const char* name, void (*timeout_callback)(void* arg), void* arg, uint32_t ticks, stimet_mode_t mode);
void stimer_start(stimer_t* timer);
void stimer_stop(stimer_t* timer);
void stimer_restart(stimer_t* timer);
void stimer_poll(void);
void stimer_ticks(void);
uint32_t stimer_getticks(const stimer_t* timer);

#endif /* STIMER_H_ */
